﻿<style>
.tableform td{padding-bottom:0px;}
</style>
<div class="tableform" style="height:420px;">
     <table>
        <tr>
            <td style=" padding-bottom:0px;">
                <div class="show_img">
                    <ul>
                        <li>
                             <a><img src="http://images.net.92hidc.net/storage/none.gif"  width="60px" height="60px"/><i></i></a>
                             <div><span  class="a_del"  onclick="javascript:SetLink()">设置</span></div>
                        </li>
                    </ul>
                </div>
            </td>
        </tr>
         <tr><td><iframe id="imageframe" name="slideframe" scrolling="no" frameborder="0" style="display: inline; height: 300px;width:655px"  scrolling="no" frameborder="0" style="display: inline; height: 300px;"></iframe></td></tr>
     </table>
</div>
<input type="hidden" id="hdimagelink" name="hdimagelink"  />
<script>
   function loadEditDialogData() {
        Hidistro_Dialog.dialogContent = $(taboverlaycontent).html();
        Hidistro_Dialog.dialogShow();
        Hidistro_Dialog.dialogTitle($(ctrnamediv).html());
        BindImageEvent();

        $(".show_img i").bind("click", function () {
            RemovetempImg(this);
        });
    }

    function BindImageEvent() {
        if (Hidistro_designer.ElementValues != null) {

            if (Hidistro_designer.ElementValues.Image != null && Hidistro_designer.ElementValues.Image != "") {
                $(".show_img img:eq(0)").attr("src", Hidistro_designer.ElementValues.Image);
            }

            if (Hidistro_designer.ElementValues.Url != null && Hidistro_designer.ElementValues.Url != "") {
                $("#hdimagelink").val(Hidistro_designer.ElementValues.Url);
            }

            if (Hidistro_designer.ElementValues.AdImageSize != null && Hidistro_designer.ElementValues.AdImageSize != "") {
                $("#imageframe").attr("src", "DialogTemplates/SelectImage.aspx?size=" + Hidistro_designer.ElementValues.AdImageSize + "&type=advertimg");
            }
        }
    }

    function SetLink() {
        var txtvalue = "http://";

        if ($("#hdimagelink").val().replace(/\s/g, "") != "") {
            txtvalue = $("#hdimagelink").val().replace(/\s/g, "");
        }

        var dialoglink = art.dialog({
            content: '<p>设置图片链接地址</p>'
    	+ '<input id="txtlinkurl" style="width:15em; padding:4px" value="' + txtvalue + '" />',
            fixed: true,
            id: 'Fm7',
            icon: 'question',
            okVal: '确定',
            ok: function () {
                var input = document.getElementById('txtlinkurl');
                $("#hdimagelink").val(input.value);
            },
            cancel: true
        });

        dialoglink.shake && dialoglink.shake(); // 调用抖动接口
    }

    //删除图片
    function RemovetempImg(currentobj) {
        if ($(currentobj).prev("img").attr("src") != "http://images.net.92hidc.net/storage/none.gif")
            $(currentobj).prev("img").attr("src", "http://images.net.92hidc.net/storage/none.gif");
    }

    //保存值
    function SaveElmentValue() {
        if ($(".show_img img:eq(0)").attr("src") == "http://images.net.92hidc.net/storage/none.gif") {
            Hidistro_Dialog.dialogTip('error', '请选择广告图片');
            return false;
        }
        
        $.ajax({
            url: "Handler/DesigAdvert.ashx",
            async: false,
            type: "post",
            data: {
                ModelId: "editeadvertimage",
                Param: "{\"Id\":\"" + Hidistro_designer.CurrentContentID +
                            "\",\"Image\":\"" + $(".show_img img:eq(0)").attr("src") +
                            "\",\"Url\": \"" + $("#hdimagelink").val() + "\"}"
            },
            dataType: "json",
            success: function (msg) {
                if (msg.success) {
                    $("#" + Hidistro_designer.CurrentContentID).replaceWith(msg.Result.AdImage);
                    Hidistro_Dialog.dialogTip("succeed", "单图广告更新成功");
                } else {
                    Hidistro_Dialog.dialogTip("error", msg.Result);
                }
            },
            complete: function () {
                Hidistro_designer.BindSingleEvent(Hidistro_designer.CurrentContentID, true);
            }
        });
    }
</script>